﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace Utils.WeChat.Helper
{
    /// <summary>
    /// 2.0接口
    /// </summary>
    public class WxPayHttpHandler2 : DelegatingHandler
    {
        public WxPayHttpHandler2(X509Certificate certificate)
        {
            var handler = new HttpClientHandler()
            {
                ServerCertificateCustomValidationCallback = CheckValidationResult
            };
            handler.ClientCertificates.Add(certificate);
            InnerHandler = handler;
        }

        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true;
        }
    }
}
